package lanou.giftsay_01.adapter;

import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentPagerAdapter;

import java.util.ArrayList;

/**
 * Created by dllo on 16/8/18.
 */

public class CgAdapter extends FragmentPagerAdapter {
    ArrayList<Fragment> arrayList ;
    ArrayList<String> title ;

    public void setArrayList(ArrayList<Fragment> arrayList) {
        this.arrayList = arrayList;
        notifyDataSetChanged();
    }

    public void setTitle(ArrayList<String> title) {
        this.title = title;
        notifyDataSetChanged();
    }

    public CgAdapter(FragmentManager fm) {
        super(fm);
    }

    @Override
    public Fragment getItem(int position) {
        return arrayList.get(position);
    }

    @Override
    public int getCount() {
        return arrayList != null ? arrayList.size():0;
    }

    @Override
    public CharSequence getPageTitle(int position) {
        return title.get(position);
    }
}
